//
//  OneOrderModel.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/1.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class OneOrderModel: NSObject {

    var evaluation_state = "-999"
    var pay_sn = "-999"
    var shipping_code = "-999"
    var if_cancel = "-999"
    var if_payment = "-999"
    var if_receive = "-999"
    var if_lock = "-999"
    var if_deliver = "-999"
    var order_state = "-999"
    var if_refund_cancel = "-999"
    var zengpin_list = "-999"
    var store_name = "-999"
    var lock_state = "-999"
    var order_id = "-999"
    var order_amount = "-999"
    var payment_code = "-999"
    var extend_order_goods = [OrderGoodsModel]()
    var order_sn = "-999"
    var shipping_fee = "-999"
    var goods_count = "-999"
    var pay_amount = "-999"
    var if_delete = "-999"
    var state_desc = "-999"
    var payment_name = "-999"
    var if_evaluation = "-999"
    
    
    
    init(dic : [String : AnyObject]) {
        super.init()
        
        setValuesForKeys(dic)
        
    }
    
    
    override func  setValue(_ value: Any?, forKey key: String) {
        
        if key == "extend_order_goods" {
            
            if let temp = value as? [[String : AnyObject]]{
                
                for dic in temp {
                    
                    extend_order_goods.append(OrderGoodsModel(dic:dic ))
                    
                }
                
                
                
            }
            
        } else {
            
            
            super.setValue(value, forKey: key)
        }
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
        
    }
    
    
    //在swift中想要打印对象要以下重写属性
    override var description: String{
        let keys = ["evaluation_state","pay_sn","shipping_code","if_cancel","if_payment","if_receive","if_lock","if_deliver","order_state","if_refund_cancel","zengpin_list","store_name","lock_state","order_id","order_amount","payment_code","extend_order_goods","order_sn","shipping_fee","goods_count","pay_amount","if_delete","state_desc","payment_name","if_evaluation"]
        let dic = dictionaryWithValues(forKeys: keys)
        return "\(dic)"
    }

}
